/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86184
 * Date: 2023-02-19
 * Time: 20:13
 */
public class OftenMethod {
    public static void main(String[] args) {

        String s = "aaabbbcccaaabbbccc";
        //遍历字符串
        for (int i = 0; i <s.length() ; i++) {
            char ch=s.charAt(i);
        }
        //寻找字符或者字符串的位置
        System.out.println(s.indexOf('c'));   //重头开始找   6
        System.out.println(s.indexOf('c',7));  //重下标7开始找   7
        System.out.println(s.indexOf("abc"));   //重头开始找字符串abc;  找不到返回-1
        System.out.println(s.indexOf("bbb"));   //重头开始找字符串bbb;  3
        System.out.println(s.indexOf("aaa",6));   //重下标6开始找字符串aaa;   9
        System.out.println(s.lastIndexOf('c'));   //重末尾开始往前找   17
        System.out.println(s.lastIndexOf('c',9));       //重下标9开始往前找 8
        System.out.println(s.lastIndexOf("ccc"));   //重末尾开始往前找  15
        System.out.println(s.lastIndexOf("ccc",9));    //重下标9开始往前找  6
    }
}
